home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
hypercrd
/
xcmd
/
xfcnmscl.sit
/
XFCN miscellany
/
stack.txt
< prev
Wrap
Text File
|
1987-11-22
|
10KB
|
305 lines
-- stack: in
-- format: 8 (HyperCard 1)
-- flags: 0x0 (none)
-- protect password hash: 0
-- maximum user level: 5 (scripting)
-- window: Rect(x1=0, y1=0, x2=0, y2=0)
-- screen: Rect(x1=0, y1=0, x2=0, y2=0)
-- card dimensions: w=0 h=0
-- scroll: x=0 y=0
-- background count: 1
-- first background id: 2690
-- card count: 6
-- first card id: 3016
-- list block id: 5041
-- print block id: 3582
-- font table block id: 0
-- style table block id: 0
-- free block count: 0
-- free size: 0 bytes
-- total size: 20768 bytes
-- stack block size: 8704 bytes
-- created by hypercard version: 0x00000000
-- compacted by hypercard version: 0x00000000
-- modified by hypercard version: 0x00000000
-- opened by hypercard version: 0x00000000
-- patterns[0]: 0x0000000000000000
-- patterns[1]: 0x0000220000002200
-- patterns[2]: 0x8800220088002200
-- patterns[3]: 0xCC003300CC003300
-- patterns[4]: 0xCC883322CC883322
-- patterns[5]: 0xFF00FF00FF00FF00
-- patterns[6]: 0xEECCBB33EECCBB33
-- patterns[7]: 0xFFCCFF33FFCCFF33
-- patterns[8]: 0xFFEEFFBBFFEEFFBB
-- patterns[9]: 0xFFFFFFBBFFFFFFBB
-- patterns[10]: 0x8010022001084004
-- patterns[11]: 0xFFFFFFFFFFFFFFFF
-- patterns[12]: 0x8822882288228822
-- patterns[13]: 0x1122448811224488
-- patterns[14]: 0xC4800C6843023026
-- patterns[15]: 0xB130031BD8C00C8D
-- patterns[16]: 0xAA00AA00AA00AA00
-- patterns[17]: 0x8822552288225522
-- patterns[18]: 0x8855225588552255
-- patterns[19]: 0x77DD77DD77DD77DD
-- patterns[20]: 0x8000000000000000
-- patterns[21]: 0xAA55AA55AA55AA55
-- patterns[22]: 0x5555555555555555
-- patterns[23]: 0x8244394482010101
-- patterns[24]: 0x8814224188412214
-- patterns[25]: 0x8080413E080814E3
-- patterns[26]: 0x22048C7422179810
-- patterns[27]: 0xBE808808EB088880
-- patterns[28]: 0x25C8328964244C92
-- patterns[29]: 0xA29C41BE2AC914EB
-- patterns[30]: 0x40A00000040A0000
-- patterns[31]: 0x8040200002040800
-- patterns[32]: 0xAA00800088008000
-- patterns[33]: 0xFF80808080808080
-- patterns[34]: 0x081C22C180010204
-- patterns[35]: 0xFF808080FF080808
-- patterns[36]: 0xF87422478F172271
-- patterns[37]: 0xBF00BFBFB0B0B0B0
-- patterns[38]: 0xFF7FBE5DA2418000
-- patterns[39]: 0xFAF5FAF5A050A050
-- checksum: 0x0
----- HyperTalk script -----
on openStack
hide message box
pass openStack
end openStack
on openCard
push recent card
pass openCard
end openCard
-- GetFullPath: a function to find the full path name of an application,
-- document or stack. The pathlist is one of 3 globals: applications,
-- documents or stacks- see getHomeInfo in the Home stack's stack script
-- For instance:
-- global stacks
-- put GetFullPath("Browser",stacks) into bpath
-- should compute the full pathname of the Browser stack (if the "Look
-- for stacks in:" card in the Home stack is up to date).
function GetFullPath name,pathlist
repeat with i = 1 to the number of lines in pathlist
if line i of pathlist is empty then next repeat -- sanity check
put line i of pathlist & name into fname
if FileModDate(fname,true) is not empty then -- found it
return fname
end if
end repeat
return empty -- file not found in pathlist
end GetFullPath
-- NumberOfChars -- utility function that tells you how many times a
-- character turns up in a string
function NumberOfChars theChar, theString
put 0 into charCount
put first character of theChar into theChar -- strip
repeat with i = 1 to the length of theString
if character i of theString is theChar then add 1 to charCount
end repeat
return charCount
end NumberOfChars
-- FileAtRoot: a function that determines if a file is present at
-- the root of a volume (i.e. not buried in a folder somewhere).
function FileAtRoot name
put NumberOfChars(":",name) into colonCount
if colonCount is 0 then
-- No colon in filename, needs expanding before calling this
-- function!
return false
end if
-- At least 1 colon. If there's more it's not at the root
if colonCount is 1 then
-- If the file exists, it's at the root.
if FileModDate(name,true) is not empty then -- empty = file not fnd.
return true
else
return false
end if
else
return false
end if
end FileAtRoot
-- VolumeName -- given a file pathname, return the name of the volume
-- it resides on. Straightforward string munging.
function VolumeName path
put empty into vol
repeat with i = 1 to the length of path
if character i of path is ":" then -- Stop at first colon
put ":" after vol
return vol
else
put character i of path after vol
end if
end repeat
-- If we reach here, there's something drastically wrong.
answer "Bad path given to VolumeName" with "OK"
return empty
end VolumeName
-- LastPathComponent -- given a file pathname, returns the last
-- component i.e. whatever comes after the last colon, if anything.
function LastPathComponent name
-- scan backwards for the last colon.
repeat with i = the length of name down to 1
if character i of name is ":" then exit repeat
end repeat
if i is 1 then
-- Name was of the form ":thing" or "thing". Check for leading
-- colon, and adjust if necessary. Done for generality.
if first character of name is ":" then
put 2 into i
end if
else
add 1 to i -- skip the colon
end if
-- Name was of the form "Thing:otherthing". Return "otherThing".
put empty into lastpath
repeat with j = i to the length of name
put character j of name after lastpath
end repeat
return lastpath
end LastPathComponent
-- InvokeApplication : run application in Finder/MultiFinder modes.
-- Will launch or sublaunch. Under MultiFinder, with normal launching,
-- attached documents will only be found if they are at the root of a
-- volume. This script will move documents to the root before issuing
-- the open command. By saving the document's original path in an
-- invisible card field, you can restore it to its original location
-- in a resume handler (not shown in this stack). This problem
-- doesn't happen if you use the sublaunch XFCN.
-- Sublaunching is suppressed (you'd do this if you didn't have enough
-- memory) if the shift key is held down, or true passed as a third
-- parameter.
on InvokeApplication progName,docName,noSubLaunch
global documents
if MultiFinder() is false then
if docName is empty then
open progName
else
open docName with progName
end if
else
if IsRunning(progName) is true then
-- Can't attach a document in this case without invoking
-- Tempo or QuicKeys. See the ΓÇ£PostEventΓÇ¥ stack for details.
doMenu progName
else
-- Not running. Launch or sublaunch it.
if the shiftKey is down or noSubLaunch is true then
-- Override: don't sublaunch, just do a normal launch.
if docName is not empty then
-- Need to move the document up to the volume root for this
-- to work properly due to MultiFinder/Hypercard bug.
if NumberOfChars(":",docName) is 0 then
-- Filename needs expanding
put GetFullPath(docName,documents) into docName
if docName is empty then
-- one reason for this would be a previous call that
-- moved the document up to the root, and the root isn't
-- on the document search path
answer "Can't find the document" with "OK"
exit InvokeApplication
end if
end if -- end NumberOfChars
-- Is this document at the root of the volume?
if FileAtRoot(docName) is false then
-- Need to move it to the root. Start by computing the
-- name of the volume.
put VolumeName(docName) into vol
if vol is empty then exit InvokeApplication
put MoveFile(docName,vol) into err
if err is not 0 then
OsErr err -- report file i/o error
exit InvokeApplication
end if
-- Document is now at the root. All we need to do is find
-- out the new name for the document.
put vol & LastPathComponent(docName) into docName
end if -- end FileAtRoot
open docName with progName
else
-- No document. Just run the application.
open progName
end if -- end docName not empty test
exit InvokeApplication
end if -- end shiftKey/override
if docName is empty then
put SubLaunch(progName) into err
else
put SubLaunch(progName,docName) into err
end if
if err is not 0 then
if err < 0 then
OsErr err
else if err is 1 then
-- Parameter error?
answer "Parameter error in sublaunch call" with "OK"
else if err is 2 then
-- System error encountered in sublaunch
answer "Insufficient memory (or already running?)" with "Failed"
end if
end if
end if
end if
end InvokeApplication
-- OsErr: for displaying Operating system error codes returned by
-- Sublaunch, RenameFile, MoveFile and DeleteFile XFCNs.
on OsErr err
-- Translate the most common ones
if err > 0 then -- XFCN convention
put "Parameter error with function" into errstr
else if err is -59 then
put "Problem during rename" into errstr
else if err is -54 then
put "Attempt to open locked file for writing" into errstr
else if err is -46 then
put "Volume locked by software" into errstr
else if err is -45 then
put "File locked" into errstr
else if err is -44 then
put "Volume locked by hardware" into errstr
else if err is -43 then
put "File not found" into errstr
else if err is -37 then
put "Bad volume or file name" into errstr
else if err is -36 then
put "I/O error" into errstr
else if err is -35 then
put "No such volume" into errstr
else if err is -34 then
put "Disk is full" into errstr
else if err is -49 then
put "File already open for writing" into errstr
else
put "Failed with error" && err into errstr
end if
answer errstr with "OK"
end OsErr